//
//  TogetherDatePickerController.m
//  Together_iOS
//
//  Created by applex on 14-3-1.
//  Copyright (c) 2014年 QIU Shuang. All rights reserved.
//

#import "TogetherDatePickerController.h"

@interface TogetherDatePickerController ()

@property (nonatomic, strong) UIDatePicker *datePicker;

@end

@implementation TogetherDatePickerController


- (void)setTimeInterval:(NSInteger)timeInterval {
    _timeInterval = timeInterval;
    self.datePicker.minuteInterval = timeInterval;
}


- (id)init
{
    self = [super init];
    if (self) {
        _datePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0.f, 250.f, 320., 216.)];
        _datePicker.datePickerMode = UIDatePickerModeTime;
        _datePicker.minuteInterval = 15;
        [self.view addSubview:_datePicker];
        
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"完成" style:UIBarButtonItemStylePlain target:self action:@selector(done:)];
    self.navigationItem.rightBarButtonItem = rightBarButtonItem;
    self.view.backgroundColor = [[UIColor alloc] initWithRed:0.965 green:0.957 blue:0.918 alpha:1];
    self.datePicker.backgroundColor = [[UIColor alloc] initWithRed:0.965 green:0.957 blue:0.918 alpha:1];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


- (void)done:(id)sender {
    if ([self.delegate respondsToSelector:@selector(datePickerController:didSelectDate:)]) {
        [self.delegate datePickerController:self didSelectDate:self.datePicker.date];
    }
    [self.navigationController popViewControllerAnimated:YES];
}

@end
